package cc.mrbird.febs.power.controller;


import cc.mrbird.febs.common.utils.R;
import cc.mrbird.febs.power.dao.MenuBindAppInfoMapper;
import cc.mrbird.febs.power.entity.MenuBindAppInfo;
import cc.mrbird.febs.power.service.IMenuBindAppInfoService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author MrBird
 */
@RestController
@RequestMapping("/power/menu-bind-app-info")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class MenuBindAppInfoController {

    private final IMenuBindAppInfoService iMenuBindAppInfoService;

    /**
     * 根据应用获取菜单信息
     * @param appId
     * @return
     */
    @GetMapping("/info/{appId}")
    public R getMenuInfoByAppId(@PathVariable("appId") Integer appId) {
        return R.ok(iMenuBindAppInfoService.getMenuInfoByAppId(appId));
    }

    /**
     * 新增菜单绑定app
     * @param menuBindAppInfo
     * @return
     */
    @PostMapping("/MenuBindAppInfoAdd")
    public R MenuBindAppInfoAdd(MenuBindAppInfo menuBindAppInfo) {
        return R.ok(iMenuBindAppInfoService.save(menuBindAppInfo));
    }

    /**
     * 修改菜单绑定app
     * @param menuBindAppInfo
     * @return
     */
    @PutMapping("/MenuBindAppInfoEdit")
    public R MenuBindAppInfoEdit(MenuBindAppInfo menuBindAppInfo) {
        return R.ok(iMenuBindAppInfoService.updateById(menuBindAppInfo));
    }

    /**
     * 通过id删除一条记录
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public R MenuBindAppInfoDel(@PathVariable Integer id) {
        return R.ok(iMenuBindAppInfoService.removeById(id));
    }
}
